<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>VIP会员</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<link href="../demo.css" rel="stylesheet" type="text/css" />
<script src="../../scripts/boot.js" type="text/javascript"></script>
<style type="text/css">
html,body {
	width: 100%;
	height: 100%;
	border: 0;
	margin: 0;
	padding: 0;
	overflow: visible;
}
</style>
</head>
<body>
	<div class="mini-toolbar" style="border: 0;">
		<table style="width: 100%;">
			<tr>
				<td style="width: 100%;"><a class="mini-button"
					iconCls="icon-remove" onclick="removeRow()" plain="true">删除</a> <span
					class="separator"></span> <a class="mini-button" iconCls="icon-add"
					plain="true" onclick="newRow();">添加</a></td>

			</tr>
		</table>
	</div>
	<!--撑满页面-->
	<div class="mini-fit" style="height: 100px;">
		<div id="datagrid1" class="mini-datagrid"
			style="width: 100%; height: 100%;" url="/ios/pages/User/viplist.do"
			idField="id" sizeList="[5,10,20,50]" allowResize="true" pageSize="20"
			allowCellEdit="true" allowCellSelect="true" multiSelect="true"
			editNextOnEnterKey="true">
			<div property="columns">
				<div type="checkcolumn" style="width: 5px;"></div>
				<div type="indexcolumn" style="width: 5px;"></div>
				<div field="userid" width="120" headerAlign="center"
					allowSort="true">会员id</div>
				<div field="username" width="120" headerAlign="center"
					allowSort="true">会员昵称</div>
				<div field="integral" width="120" headerAlign="center"
					allowSort="true">总积分</div>
				<div field="huIntegral" width="100" allowSort="true"
					headerAlign="center">兑换积分</div>
				<div field="extensionNumber" width="100" allowSort="true"
					renderer="onNumberRenderer">下线数</div>
			</div>
		</div>
	</div>
	<!--添加和编辑页面-->
	<div id="editWindow" class="mini-window" title="添加会员id"
		style="width: 300px; height: 110px; display: none;" showModal="true"
		allowResize="true" iconCls="icon-save" allowDrag="true">
		<div id="editform" class="form">
			<input class="mini-textbox" name="userid" id="userid"
				style="width: 100%; height: 80%"></input>
			<div align="right" style="padding: 10px">
				<a class="mini-button" iconCls="icon-save"
					href="javascript:saveRow()">保存</a> <a class="mini-button"
					iconCls="icon-close" href="javascript:cancelRow()">关闭</a>
			</div>
		</div>
	</div>
	<script type="text/javascript">
		mini.parse();
		var form = new mini.Form("#editform");
		var editWindow = mini.get("#editWindow");
		var grid = mini.get("datagrid1");
		grid.load();

		function search() {
			var key = mini.get("key").getValue();
			grid.load({
				username : key
			});
			grid.clearSelect();
		}

		function newRow() {
			form.clear();
			editWindow.show();
		}

		function cancelRow() {
			editWindow.hide();
		}

		function saveRow() {
			form.validate();
			if (form.isValid() == false)
				return;
			var userid = mini.get("userid").getValue();
			form.loading();
			$.ajax({
				url : "/ios/pages/User/updateIsvip.do?userid=" + userid,
				success : function(text) {
					var o = mini.decode(text);
					if (o.state) {
						form.unmask();
						grid.load();
						editWindow.hide();
					} else {
						form.unmask();
						alert("未有此用户id!");
					}
				},
				error : function(jqXHR, textStatus, errorThrown) {
					alert("请求出错了!");
				}
			});
		}

		function removeRow() {
			var rows = grid.getSelecteds();
			var userids = "";
			for (i = 0; i < rows.length; i++) {
				userids += "'" + rows[i].userid + "',,,,,,,,,,";
			}
			mini.confirm("确定删除记录？", "确定？", function(action, value) {
				if (action == "ok") {
					if (rows.length > 0) {
						var messageid = mini.loading("正在执行...", "wait");
						$.ajax({
							url : "/ios/pages/User/updateIsvips.do?userids="
									+ userids,
							success : function(text) {
								var o = mini.decode(text);
								mini.hideMessageBox(messageid);
								if (o.state) {
									grid.load();
								} else {
									mini.alert("删除出错");
								}
							},
							error : function() {
								mini.hideMessageBox(messageid);
								mini.alert("删除出错");
							}
						});
					} else {
						return;
					}
				} else {
					return;
				}
			}, true);
		}
	</script>
</body>
</html>

